package com.mygdx.game.part2;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.physics.box2d.Body;

/**
 * BodyUtils
 * Created by 80002023 on 2016/8/15.
 */
public class BodyUtils {

    public static boolean isRunner(Body body) {
        UserData userData = (UserData) body.getUserData();
        return userData != null && userData.getUserDataType() == UserDataType.RUNNER;
    }

    public static boolean isGround(Body body) {
        UserData userData = (UserData) body.getUserData();
        return userData != null && userData.getUserDataType() == UserDataType.GROUND;
    }

    public static boolean inBounds(Body body) {
        UserData userData = (UserData) body.getUserData();
//        Gdx.app.log("BodyUtils","inBounds body type: " + userData.userDataType);
        switch (userData.getUserDataType()) {
            case RUNNER:
            case ENEMY:
                return body.getPosition().x + userData.getWidth() / 2 > 0;
        }

        return true;
    }

    public static boolean isEnemy(Body body) {
        UserData userData = (UserData) body.getUserData();
        //Gdx.app.log("BodyUtils" + Gdx.graphics.getDeltaTime(), "isEnemy body type: " + userData.userDataType);
        return userData != null && userData.getUserDataType() == UserDataType.ENEMY;
    }

}
